package com.wxy.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.wxy.client.userClient;

import io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;

@RestController
@RequestMapping("/circuitsc02")
public class CircuitController {
	@Autowired
	private userClient userClient;
	@RequestMapping("/circuit/{id}")
	@CircuitBreaker(name="userservice",fallbackMethod="myCircuitFallback")
	public String circuit(@PathVariable("id") int id) {
		return userClient.getMessage(id);
	}
	public String myCircuitFallback(int id,Throwable t) {
		return "myCircuitFallback,系统繁忙，请稍后重试------";
	}
}
